{% extends "base.html" %}
{% block smart_home %}
    <div class="row">
        <div class="col s4">
            <!-- Dashboard for some updates in nearby locations.  -->
            <a href="#" class="btn waves-effect z-dpeth-0" id="refresh_data">Refresh</a>
            <div class="card teal whiten-2 z-depth-0">
                <div class="card-content white-text">
                    <span class="card-title">Announcements !</span>
                    <div class="row">
                        <span> Medicines have come to the hospital !</span>
                    </div>
                    <div class="row">
                        <span> Fresh groceries - Order now !</span>
                    </div>
                    <div class="row">
                        <span> Enroll your kids to the ABC school for all round development !</span>
                    </div>
                    <div class="row">
                        <span> Book movie tickets at the lowest prices for an enjoyable evening !</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col s8">
                {% for house_data in data %}
                    <div class="card-panel z-depth-0">
                        <span>{{ house_data.push_btn_1 }}</span> called on <span>{{ house_data.date }}</span>
                    </div>
                {% endfor %}
            </div>
        </div>
    </div>

    {% block house_static %}
        <!-- <script src="https://www.gstatic.com/firebasejs/5.10.1/firebase-app.js"></script>
        <script src="https://www.gstatic.com/firebasejs/5.10.1/firebase-firestore.js"></script> -->
        <script>
            // Initialize Firebase
            // var config = {
            // apiKey: "AIzaSyBtX5YAvqEleUitoziBOshCXdjX2nzNj_c",
            // authDomain: "smart-city-61e3d.firebaseapp.com",
            // databaseURL: "https://smart-city-61e3d.firebaseio.com",
            // projectId: "smart-city-61e3d",
            // storageBucket: "smart-city-61e3d.appspot.com",
            // messagingSenderId: "1023785624836"
            // };
            // firebase.initializeApp(config);

            // const db = firebase.firestore();
            // let house_info = document.getElementById("house_info");
        
            // db.collection('apartment').onSnapshot(snapshot => {
            //     snapshot.docChanges().forEach(change => {
                
            //     if (change.type === "added") {
            //         for (const key of Object.keys(change.doc.data())) {
            //                 house_info.innerHTML += `
            //                     <div class="card-panel z-depth-0 ${key}">
            //                         <span>${change.doc.data()[key]}</span>
            //                     </div>
            //                 `;
            //             }
            //         }
            //     });
            // });

            const get_data = document.getElementById("refresh_data");
            get_data.addEventListener("click", (event) => {
                event.preventDefault();
                setTimeout(() => {
                    window.location.reload();
                }, 1000);
                console.log("Pressed");
            })
        </script>
        <script src="{{ url_for('static', filename='js/database.js') }}"></script>
    {% endblock house_static %}
{% endblock smart_home %}
